package com.angis.fx.util;

import java.util.UUID;

import android.content.ContentValues;

import com.angis.fx.data.CKTypeInfo;
import com.angis.fx.data.DraftInfo;
import com.angis.fx.data.DutyInfo;
import com.angis.fx.data.GISZFJGInfo;
import com.angis.fx.db.BusinessTypeDBHelper;
import com.angis.fx.db.CheckDraftDBHelper;
import com.angis.fx.db.DutyInfoDBHelper;
import com.angis.fx.db.EcnomicTypeDBHelper;
import com.angis.fx.db.GISZFJGDBHelper;
import com.angis.fx.db.WGTypeDBHelper;
import com.angis.fx.db.ZCTypeDBHelper;

public class ContentValuesUtil {

	public static ContentValues convertWGType(CKTypeInfo pWGTypeInfo) {
		ContentValues lValues = new ContentValues();
		lValues.put(WGTypeDBHelper.PK_WID, pWGTypeInfo.getWid());
		lValues.put(WGTypeDBHelper.COLUMN_CONDITIONTYPE, pWGTypeInfo.getConditionType());
		lValues.put(WGTypeDBHelper.COLUMN_WGTYPE, pWGTypeInfo.getWgType());
		lValues.put(WGTypeDBHelper.COLUMN_CREATIONTIME, pWGTypeInfo.getCreationTime());
		return lValues;
	}
	
	public static ContentValues convertZCType(CKTypeInfo pZCTypeInfo) {
		ContentValues lValues = new ContentValues();
		lValues.put(ZCTypeDBHelper.PK_ZID, pZCTypeInfo.getWid());
		lValues.put(ZCTypeDBHelper.COLUMN_ZCONDITIONTYPE, pZCTypeInfo.getConditionType());
		lValues.put(ZCTypeDBHelper.COLUMN_ZWGTYPE, pZCTypeInfo.getWgType());
		lValues.put(ZCTypeDBHelper.COLUMN_ZCREATIONTIME, pZCTypeInfo.getCreationTime());
		return lValues;
	}
	
	public static ContentValues convertEcnomicType(String pDesc) {
		ContentValues lValues = new ContentValues();
		lValues.put(EcnomicTypeDBHelper.COLUMN_EID, UUID.randomUUID().toString());
		lValues.put(EcnomicTypeDBHelper.COLUMN_EDESC, pDesc);
		return lValues;
	}
	
	public static ContentValues convertBusinessType(String pDesc) {
		ContentValues lValues = new ContentValues();
		lValues.put(BusinessTypeDBHelper.COLUMN_BID, UUID.randomUUID().toString());
		lValues.put(BusinessTypeDBHelper.COLUMN_BDESC, pDesc);
		return lValues;
	}
	
	public static ContentValues convertGISZFJG(GISZFJGInfo pGISZFJGInfo) {
		ContentValues lValues = new ContentValues();
		lValues.put(GISZFJGDBHelper.PK_ZFID, UUID.randomUUID().toString());
		lValues.put(GISZFJGDBHelper.COLUMN_USERLAYER, pGISZFJGInfo.getUserlayer());
		lValues.put(GISZFJGDBHelper.COLUMN_X, pGISZFJGInfo.getX());
		lValues.put(GISZFJGDBHelper.COLUMN_Y, pGISZFJGInfo.getY());
		return lValues;
	}
	
	public static ContentValues convertCheckDraft(DraftInfo pDraftInfo) {
		ContentValues lValues = new ContentValues();
		lValues.put(CheckDraftDBHelper.PK_ID, pDraftInfo.getId());
		lValues.put(CheckDraftDBHelper.COLUMN_CSID, pDraftInfo.getCsid());
		lValues.put(CheckDraftDBHelper.COLUMN_CONTITLE, pDraftInfo.getContitle());
		lValues.put(CheckDraftDBHelper.COLUMN_ADDRESS, pDraftInfo.getAddress());
		lValues.put(CheckDraftDBHelper.COLUMN_MANAGER, pDraftInfo.getManager());
		lValues.put(CheckDraftDBHelper.COLUMN_AREATYPE, pDraftInfo.getAreatype());
		lValues.put(CheckDraftDBHelper.COLUMN_PERMITCODE, pDraftInfo.getPermitword());
		lValues.put(CheckDraftDBHelper.COLUMN_PERMITWORD, pDraftInfo.getPermitword());
		lValues.put(CheckDraftDBHelper.COLUMN_AREA, pDraftInfo.getArea());
		lValues.put(CheckDraftDBHelper.COLUMN_AREACODE, pDraftInfo.getAreacode());
		lValues.put(CheckDraftDBHelper.COLUMN_HYCODE, pDraftInfo.getHycode());
		lValues.put(CheckDraftDBHelper.COLUMN_CODE, pDraftInfo.getCode());
		lValues.put(CheckDraftDBHelper.COLUMN_MANAGEPOS, pDraftInfo.getManagepos());
		lValues.put(CheckDraftDBHelper.COLUMN_TEL, pDraftInfo.getTel());
		lValues.put(CheckDraftDBHelper.COLUMN_UNITTYPE, pDraftInfo.getUnittype());
		lValues.put(CheckDraftDBHelper.COLUMN_JCJG, pDraftInfo.getJcjg());
		lValues.put(CheckDraftDBHelper.COLUMN_JCSJ, pDraftInfo.getJcsj());
		lValues.put(CheckDraftDBHelper.COLUMN_JCQK, pDraftInfo.getJcqk());
		lValues.put(CheckDraftDBHelper.COLUMN_JCJGDETAIL, pDraftInfo.getJcjgdetail());
		lValues.put(CheckDraftDBHelper.COLUMN_TOGETHER, pDraftInfo.getTogether());
		lValues.put(CheckDraftDBHelper.COLUMN_OTHERUSER, pDraftInfo.getOtheruser());
		lValues.put(CheckDraftDBHelper.COLUMN_WHCSDUTYID, pDraftInfo.getWhcsdutyid());
		lValues.put(CheckDraftDBHelper.COLUMN_TJGUID, pDraftInfo.getTjguid());
		lValues.put(CheckDraftDBHelper.COLUMN_CSLB, pDraftInfo.getCslb());
		lValues.put(CheckDraftDBHelper.COLUMN_USER_NAME, pDraftInfo.getUser_name());
		lValues.put(CheckDraftDBHelper.COLUMN_ARRIVALTIME, pDraftInfo.getArrivaltime());
		lValues.put(CheckDraftDBHelper.COLUMN_LEAVETIME, pDraftInfo.getLeavetime());
		lValues.put(CheckDraftDBHelper.COLUMN_DUTYNO, pDraftInfo.getDutyno());
		lValues.put(CheckDraftDBHelper.COLUMN_DJGUID, pDraftInfo.getDjguid());
		lValues.put(CheckDraftDBHelper.COLUMN_CHECKXS, pDraftInfo.getCheckxs());
		lValues.put(CheckDraftDBHelper.COLUMN_CDRC, pDraftInfo.getCdrc());
		lValues.put(CheckDraftDBHelper.COLUMN_CHECKAREA, pDraftInfo.getCheckarea());
		lValues.put(CheckDraftDBHelper.COLUMN_DATASTATUS, pDraftInfo.getDatastatus());
		lValues.put(CheckDraftDBHelper.COLUMN_TYCODE, pDraftInfo.getTycode());
		lValues.put(CheckDraftDBHelper.COLUMN_X, pDraftInfo.getX());
		lValues.put(CheckDraftDBHelper.COLUMN_Y, pDraftInfo.getY());
		lValues.put(CheckDraftDBHelper.COLUMN_XLONGPS, pDraftInfo.getXlongps());
		lValues.put(CheckDraftDBHelper.COLUMN_YLATGPS, pDraftInfo.getYlatgps());
		lValues.put(CheckDraftDBHelper.COLUMN_CHECKTIME, pDraftInfo.getChecktime());
		return lValues;
	}
	
	public static ContentValues convertDutyInfo(DutyInfo pDutyInfo) {
		ContentValues lValues = new ContentValues();
		if(isNotBlank(pDutyInfo.getDusername())) {
			lValues.put(DutyInfoDBHelper.COLUMN_DUSERNAME, pDutyInfo.getDusername());
		}
		if(isNotBlank(pDutyInfo.getDutyno())) {
			lValues.put(DutyInfoDBHelper.PK_DUTYNO, pDutyInfo.getDutyno());
		}
		if(isNotBlank(pDutyInfo.getStartdutytime())) {
			lValues.put(DutyInfoDBHelper.COLUMN_STARTDUTYTIME, pDutyInfo.getStartdutytime());
		}
		if(isNotBlank(pDutyInfo.getEnddutytime())) {
			lValues.put(DutyInfoDBHelper.COLUMN_ENDDUTYTIME, pDutyInfo.getEnddutytime());
		}
		if(isNotBlank(pDutyInfo.getDutystatus())) {
			lValues.put(DutyInfoDBHelper.COLUMN_DUTYSTATUS, pDutyInfo.getDutystatus());
		}
		if(isNotBlank(pDutyInfo.getMctjuuid())) {
			lValues.put(DutyInfoDBHelper.COLUMN_MCTJUUID, pDutyInfo.getMctjuuid());
		}
		if(isNotBlank(pDutyInfo.getAftjuuid())) {
			lValues.put(DutyInfoDBHelper.COLUMN_AFTJUUID, pDutyInfo.getAftjuuid());
		}
		if(isNotBlank(pDutyInfo.getMcareacode())) {
			lValues.put(DutyInfoDBHelper.COLUMN_MCAREACODE, pDutyInfo.getMcareacode());
		}
		if(isNotBlank(pDutyInfo.getAfareacode())) {
			lValues.put(DutyInfoDBHelper.COLUMN_AFAREACODE, pDutyInfo.getAfareacode());
		}
		if(isNotBlank(pDutyInfo.getSxry())) {
			lValues.put(DutyInfoDBHelper.COLUMN_SXRY, pDutyInfo.getSxry());
		}
		if(isNotBlank(pDutyInfo.getTogetheruser())) {
			lValues.put(DutyInfoDBHelper.COLUMN_TOGETHERUSER, pDutyInfo.getTogetheruser());
		}
		if(isNotBlank(pDutyInfo.getOtheruser())) {
			lValues.put(DutyInfoDBHelper.COLUMN_OTHERUSER, pDutyInfo.getOtheruser());
		}
		if(isNotBlank(pDutyInfo.getOthercount())) {
			lValues.put(DutyInfoDBHelper.COLUMN_OTHERCOUNT, pDutyInfo.getOthercount());
		}
		if(isNotBlank(pDutyInfo.getCdrc())) {
			lValues.put(DutyInfoDBHelper.COLUMN_CDRC, pDutyInfo.getCdrc());
		}
		return lValues;
	}
	
	private static boolean isNotBlank(String pStr) {
		if(null == pStr) {
			return false;
		}
		if(pStr.trim().length() < 1) {
			return false;
		}
		return true;
	}
	
}
